import functools
import itertools
import operator
import sys
import types



class Qiao(type):
    def __new__(mcs, name, bases, attrs):
    #def __new__(mcs):
        print('Qiao.__new__')
        current_fields = []
        #for key, value in list(attrs.items()):
        #    if isinstance(value, object):
        #        current_fields.append((key, value))
        new_class = super(Qiao, mcs).__new__(mcs, name, bases, attrs)
        new_class.qiao_name = 'qiao_name'
        return new_class

    def QiaoIndex(self):
        print('QiaoIndex')

class AnSheng(object):
    def __init__(self, **kwargs):
        self.name1111 = 'woshi name1111'
        return super().__init__(**kwargs)

    def anShent_index(self):
        print('anShent_index')

def with_metaclass11(meta, *bases):
    class metaclass(meta):
        print(111)
        print('{:-^60}'.format('分割线'))
        print(meta)
        print('{:-^60}'.format('分割线'))
        print(*bases)
        print('{:-^60}'.format('分割线'))
        def __new__(cls, name, this_bases, d):
            print(222)
            #attrs['add'] = lambda self, value: self.append(value)
            return meta(name, bases, d)
    return type.__new__(metaclass, 'temporary_class', (), {})

class IAnSheng(with_metaclass11(Qiao,AnSheng)):
    "这是一个啥啊"
class HH(IAnSheng):
    name = '乔安生'


if __name__ == '__main__':
    oo1 = with_metaclass11(Qiao, AnSheng);
    print(oo1) #输出：<class '__main__.temporary_class'>
    oo2 = HH();
    print(oo2.name)
    oo2.anShent_index()
    print(oo2.qiao_name)
    #oo2.QiaoIndex()
    #print(oo1.name1111) #输出：type object 'temporary_class' has no attribute 'name1111'
    #oo1.add(123)
    #print(oo1.getattr())
